CODENVY_DATA_DIR=/opt/codenvy-data
CODENVY_JAVA_DUMPS_DIR=/opt/codenvy-data/dumps
CHE_LOGS_DIR=/opt/codenvy-data/logs
CHE_LOCAL_CONF_DIR=/opt/codenvy-data/conf/
DOCKER_HOST=tcp://socat:2375
CODENVY_HOST=<%= scope.lookupvar('codenvy::host_url') -%>

CODENVY_DOCKER_IP=<%= scope.lookupvar('codenvy::docker_ip') -%>

PUPPET_SOURCE=<%= scope.lookupvar('codenvy::puppet_src_folder') -%>

PUPPET_DESTINATION=<%= scope.lookupvar('codenvy::codenvy_folder') -%>

PGUSER=<%= scope.lookupvar('codenvy::pgsql_username') %>
PGPASSWORD=<%= scope.lookupvar('codenvy::pgsql_pass') -%>

# needed for overriding classpath
CODENVY_TOMCAT_HOME=/opt/codenvy-tomcat

<% if scope.lookupvar('codenvy::env') != "production" -%>
JPDA=jpda
JPDA_ADDRESS=<%= scope.lookupvar('codenvy::codenvy_debug_port') %>
<% if scope.lookupvar('codenvy::codenvy_debug_suspend') == "true" %>JPDA_SUSPEND=y<% end -%>
<% end %>

CATALINA_OPTS=-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=<%= scope.lookupvar('codenvy::host_url') %> -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/opt/codenvy-data/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/opt/codenvy-data/conf/jmxremote.access -Dcom.sun.management.jmxremote.ssl=false

<% if ! @http_proxy_for_codenvy.empty? or ! @https_proxy_for_codenvy.empty? -%>
JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true
<% end -%>
<% if ! @http_proxy_for_codenvy.empty? -%>
<% if ! @http_proxy_for_codenvy.empty? and @http_proxy_for_codenvy.include? '@' -%>
JAVA_HTTP_USER_NAME=-Dhttp.proxyUser=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %>
JAVA_HTTP_USER_PASSWORD=-Dhttp.proxyPassword=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %>
JAVA_HTTP_PROXY_HOST=-Dhttp.proxyHost=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %>
JAVA_HTTP_PROXY_PORT=-Dhttp.proxyPort=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %>
<% else -%>
JAVA_HTTP_PROXY_HOST=-Dhttp.proxyHost=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %>
JAVA_HTTP_PROXY_PORT=-Dhttp.proxyPort=<%= @http_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %>
<% end -%>
<% end -%>
<% if ! @https_proxy_for_codenvy.empty? -%>
<% if @https_proxy_for_codenvy.include? '@' -%>
JAVA_HTTPS_USER_NAME=-Dhttps.proxyUser=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %>
JAVA_HTTPS_USER_PASSWORD=-Dhttps.proxyPassword=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %>
JAVA_HTTPS_PROXY_HOST=-Dhttps.proxyHost=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %>
JAVA_HTTPS_PROXY_PORT=-Dhttps.proxyPort=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %>
<% else -%>
JAVA_HTTPS_PROXY_HOST=-Dhttps.proxyHost=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %>
JAVA_HTTPS_PROXY_PORT=-Dhttps.proxyPort=<%= @https_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %>
<% end -%>
<% end -%>
<% if ! @no_proxy_for_codenvy.empty? -%>
JAVA_NO_PROXY=-Dhttp.nonProxyHosts='<%= @no_proxy_for_codenvy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(",").uniq.join("|") %>|'
<% end -%>

JAVA_OPTS=-Xms512m -Xmx<%= @codenvy_server_xmx %>m -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${CODENVY_JAVA_DUMPS_DIR} -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark -Dche.local.conf.dir=${CHE_LOCAL_CONF_DIR} -Dauth.handler.default=<%= scope.lookupvar('codenvy::auth_handler_default') %> <% if ! @http_proxy_for_codenvy.empty? or ! @https_proxy_for_codenvy.empty? -%>$JAVA_HTTP_PROXY_SET<% end -%> <% if ! @http_proxy_for_codenvy.empty? -%>$JAVA_HTTP_PROXY_HOST $JAVA_HTTP_PROXY_PORT<% end -%> <% if ! @https_proxy_for_codenvy.empty? -%>$JAVA_HTTPS_PROXY_HOST $JAVA_HTTPS_PROXY_PORT<% end -%><%- if ! @no_proxy_for_codenvy.empty? -%> $JAVA_NO_PROXY<% end -%><% if @http_proxy_for_codenvy.include? '@' -%> $JAVA_HTTP_USER_NAME $JAVA_HTTP_USER_PASSWORD<% end -%><% if @https_proxy_for_codenvy.include? '@' -%> $JAVA_HTTPS_USER_NAME $JAVA_HTTPS_USER_PASSWORD<% end %>

# docker private registries
<% ENV.each do |k,v| -%>
<% if k.include? "DOCKER_REGISTRY_AUTH_" then  -%>
<%= k.gsub(/^CODENVY_/,'CHE_') + '=' + v %>
<% end -%>
<% end -%>

# docker private registries for aws ecr
<% ENV.each do |k,v| -%>
<% if k.include? "DOCKER_REGISTRY_AWS_" then  -%>
<%= k + '=' + v %>
<% end -%>
<% end -%>

# integration jenkins connectors
<% ENV.each do |k,v| -%>
<% if k.include? "CODENVY_JENKINS_" then  -%>
<%= k + '=' + v %>
<% end -%>
<% end -%>

# integration GitHub webhooks
<% ENV.each do |k,v| -%>
<% if k.include? "CODENVY_GITHUB_" then  -%>
<%= k + '=' + v %>
<% end -%>
<% end -%>

# integration Bitbucket Server webhooks
<% ENV.each do |k,v| -%>
<% if k.include? "CODENVY_BITBUCKET_SERVER_" then  -%>
<%= k + '=' + v %>
<% end -%>
<% end -%>
